package cn.com.connected.vo.wechat;

import lombok.Data;

@Data
public class BaseAccessToken {

	/**
	 * 网页授权接口调用凭证
	 */
	private String access_token;

	/**
	 * 过期时间
	 */
	private int expires_in;

	/**
	 * 创建时间
	 */
	private long create_time;
	
	public BaseAccessToken(){
		this.create_time=System.currentTimeMillis();
	}

	public boolean isVail(){
		return isVail(600);
	}

	public boolean isVail(int beforehand){
        long passTime = (System.currentTimeMillis()-create_time)/1000;
        if(passTime>=(expires_in-beforehand)){
            return false;
        }else{
            return true;
        }
    }
}
